// #ifndef VUE3
import Vue from 'vue';
import App from './App';
//国际化
import RU from '@/lang/ru-RU.json';
import CN from '@/lang/zh-CN.json';
import {
	LOCALE,
	HTTP_IMG_UTL
} from "@/config/app";
import VueI18n from 'vue-i18n' // v8.x

import { isMessageGo,vipPrivilegeGet } from '@/assets/public.js';
import { chooseFile } from '@/assets/public.js';

import httpInterceptor from '@/assets/http.interceptor.js'
import httpApi from '@/assets/http.api.js'

import flag from '@/components/flag.vue'
import tipSl from '@/components/tipSl/tipSl.vue'
import "@/assets/web-view.js"

import  routeInterceptor from "@/assets/route.interceptor.js";
import { unAuthRedirect } from "@/assets/public.js";
Vue.component('flag', flag)
Vue.component('tipSl', tipSl)


Vue.config.productionTip = false;
Vue.prototype.$eventBus = new Vue()
Vue.prototype.serverImageUrl = (path) => {
	return HTTP_IMG_UTL.substr(0, HTTP_IMG_UTL.length - 1) + path
}
Vue.prototype.langKey = (item, key) => {
	return uni.getStorageSync("lang") == 'zh' ? item[key] : item[key + '_ru']
}

// 追加后缀 
Vue.prototype.plang = (key) => {
	let isZh = uni.getStorageSync("lang") == 'zh'
	return isZh ? key : key + '_ru'
}

Vue.prototype.plangJava = (key) => {
	let isZh = uni.getStorageSync("lang") == 'zh'
	return isZh ? key : key + 'Ru'
}

Vue.prototype.langR =  uni.getStorageSync("lang")

// 单位转换 卢布和人民币
Vue.prototype.unit = () => {
	let isZh = uni.getStorageSync("lang") == 'zh'
	return isZh ? '￥' : '₽'
}


Vue.prototype.getImageUrl = (url = '') => {
	url = !!url ? url : '';
	if(url.indexOf('://') > -1) {
		return url
	} else {
		return "https://gluz-oss.oss-cn-beijing.aliyuncs.com" + url
	}
};

Vue.prototype.unAuthRedirect = unAuthRedirect
Vue.prototype.vipPrivilegeGet = vipPrivilegeGet

// 路由拦截
routeInterceptor();

const messages = {
	'ru': RU,
	'zh': CN,
}
let i18nConfig = {
	locale: LOCALE, // 获取已设置的语言
	messages,
	silentTranslationWarn: true, // 去除国际化警告
}
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)
Vue.prototype._i18n = i18n

// 引入全局uView
import uView from 'uview-ui'
import getMethod from "./plugin/get.js"

Vue.use(getMethod)

import city from '@/components/city.vue'
Vue.component('city', city)

Vue.prototype.isMessageGo = isMessageGo
Vue.prototype.chooseFile = chooseFile


Vue.use(uView);


import CommonLoading from "@/pages/components/common-loading.vue";
Vue.component("CommonLoading", CommonLoading)

App.mpType = 'app';

import store from './store'
Vue.prototype.$store = store

const app = new Vue({
	i18n,
	store,
	...App
})
// http请求拦截器
Vue.use(httpInterceptor, app)
// api集中管理
Vue.use(httpApi, app)
app.$mount()


export default app
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue';
import App from './App.vue';
export function createApp() {
	const app = createSSRApp(App);
	return {
		app
	}
}
// #endif